

package com.kimo.shop.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kimo.shop.bean.dto.OrderRefundDto;
import com.kimo.shop.bean.model.OrderRefund;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kimo.shop.bean.param.ProdEffectRespParam;
import com.kimo.shop.bean.param.StatisticsRefundParam;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface OrderRefundMapper extends BaseMapper<OrderRefund> {

    /**
     * 获取分页列表
     */
    IPage<OrderRefundDto> getPage(Page page, @Param("orderRefundDto") OrderRefundDto orderRefundDto, @Param("beginTime") String beginTime, @Param("endTime") String endTime);

    /**
     * 获取详情信息
     */
    OrderRefundDto getById(@Param("id") Long id);

    /**
     * 通过退款编号获取退款订单
     */
    OrderRefundDto getOrderRefundByRefundSn(@Param("refundSn") String refundSn);

    /**
     * 更新退款申请状态
     */
    int updateRefundApplyStsByRefundSn(@Param("refundSn") String refundSn, @Param("status") Integer status);

    /**
     * 更新退款状态
     */
    void updateReturnMoneySts(@Param("refundList") List<OrderRefund> refundList, @Param("status") Integer status);

    /**
     * 根据订单id获取正在处理的退款订单
     */
    List<OrderRefund> getProcessingOrderRefundByOrderId(@Param("orderId") Long orderId);


    /**
     * 获取首页商家的退款信息
     */
    StatisticsRefundParam getRefundByShopId(@Param("shopId") Long shopId, @Param("startTime") Date beginTime, @Param("endTime") Date endTime);

    /**
     * 通过时间获取商家每天的退款信息
     */
    List<StatisticsRefundParam> getRefundByShopIdAndDay(@Param("shopId") Long shopId, @Param("startTime") Date beginTime, @Param("endTime") Date endTime);

    /**
     * 获取退款商品信息排行
     */
    List<StatisticsRefundParam> getRefundRankingByProd(@Param("shopId") Long shopId, @Param("startTime") Date beginTime,
                                                       @Param("endTime") Date endTime, @Param("dbLang") Integer dbLang);

    /**
     * 获取退款原因排行
     */
    List<StatisticsRefundParam> getRefundRankingByReason(@Param("shopId") Long shopId, @Param("startTime") Date beginTime, @Param("endTime") Date endTime);


    Integer getOrderRefundCountByRefundSn(@Param("refundSn") String refundSn);

    Integer countRefundByOrderItem(@Param("orderItemId") Long orderItemId, @Param("returnMoneySts0") Integer returnMoneySts0, @Param("returnMoneySts1") Integer returnMoneySts1);

    Double countRefundAmountByUserId(@Param("userId") String userId);

    Integer countRefundNumByUserId(@Param("userId") String userId);

    List<ProdEffectRespParam> getProdEffectByDateAndProdIds(@Param("prodIds") List<Long> prodIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
